<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Classroom/campus')}">校区管理</a></li>
        <li class="active"><a href="{:url('Classroom/add_campus')}">添加校区</a></li>
    </ul>
    <form action="{:url('Classroom/add_campus_Post')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="100px">校区名称<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="name"
                                   id="name" required="required" value="{$param['name']|default=''}" placeholder="请输入校区名称"/>
                        </td>
                    </tr>
                    <tr>
                        <th>校区电话<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" required="required" name="tel" id="tel" value="{$param['tel']|default=''}"
                                   placeholder="请输入校区电话">
                        </td>
                    </tr>
                    <tr>
                        <th>校区地址<span class="form-required">*</span></th>
                        <td>
						<span>
                            <input style="width:84%;float:left" class="form-control" type="text" required="required" name="address" id="address" value="{$param['address']|default=''}"
                                   placeholder="请输入校区地址">
							<input style="width:15%;float:right" id="search" type="button" class="btn btn-primary" value="搜索" />
							</span>
                        </td>
                    </tr>
					<tr>
                        <th>校区邮编</th>
                        <td>
                            <input class="form-control" type="text" required="required" name="zip" id="zip" value="{$param['zip']|default=''}"
                                   placeholder="请输入校区邮编">
                        </td>
                    </tr>
					<tr>
                        <th>校区坐标</th>
                        <td>
                            <input class="form-control" type="text" required="required" name="location_view" id="location_view" value="" placeholder="请输入校区坐标" readonly="true">
							<input type="hidden" required="required" name="lng" id="lng" value="{$param['lng']|default=''}" />
							<input type="hidden" required="required" name="lat" id="lat" value="{$param['lat']|default=''}" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="col-md-6">
				<div id="allmap" style="height:300px"></div>
            </div>
			<div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                        <input class="btn btn-primary" type="button" value="返回" onclick="javascript:history.back(-1)"></input>
                    </div>
                </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=T3boKpXs1YHVgFhFBuljeOsHltRqE5U4"></script>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用  
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用  
    map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件  
    map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件  
    map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));   //右下角，打开
	var local = new BMap.LocalSearch(map, {
		renderOptions:{map: map}
	});	
	// 搜索成功后自动填入location坐标点
	local.setSearchCompleteCallback(function(r){
		var poi = r.getPoi(0);
		$("#location_view").val(poi.point.lng + "," + poi.point.lat);
		$("#lng").val(poi.point.lng);
		$("#lat").val(poi.point.lat);
	});
	map.centerAndZoom("成都");           
	//单击获取点击的经纬度
	map.addEventListener("click",function(e){
		$("#location_view").val(e.point.lng + "," + e.point.lat);
		$("#lng").val(e.point.lng);
		$("#lat").val(e.point.lat);
	});
	//搜索地址并标注
	$("#search").click(function(){
		local.search($("#address").val());
	});
</script>
</body>
</html>